#include "component.h"

#include "entity.h"

Entity::Entity(unsigned int id) {
	m_ID = id;
}

//AddComponent
void Entity::AddComponent(std::shared_ptr<Component> component) {

	m_Components[std::type_index(typeid(*component))] = component;
}

//GetComponent
template <typename T>
std::shared_ptr<T> Entity::GetComponent(){

	std::type_index index(typeid(T));
	if(m_Components.count(std::type_index(typeid(T))) != 0) {
		return static_pointer_cast<T>(m_Components[index]);
	} else {
		return nullptr;
	}
}

//GetID
unsigned int Entity::GetID() {
	return m_ID;
}